/*
  (C) 2007 - Boston University
  Contact: Michael Ocean 

	this file was adapted from a CS511 submission

  This work is a part of the larger snBench project.  Information
  can be found at: http://csr.bu.edu/snbench 

  This program is free software; you can redistribute it and/or
  modify it under the terms of Version 2 of the GNU General Public 
  License.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package stepide;

import stepide.IDEStarter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import step.Node;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class NodeOption extends javax.swing.JDialog {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected JButton jOK;
	protected JTextField jID;
	protected JLabel jIDLabel;
	protected JButton jCancel;
	protected Node node;
	protected JFrame frame;
		
	public NodeOption(JFrame frame, Node n) {	
		super(frame);
		this.node = n;
		this.frame = frame;
		initGUI();
	}
	
	/* changing a node's ID is a very bad idea... */
	public void changeNodeID() 
	{
		node.setID(jID.getText());
	}
	
	private void jOKActionPerformed(ActionEvent evt) {
		changeNodeID();
		
		((IDEStarter)frame).refreshXML();
		frame.repaint();
		dispose();
	}
	
	private void jCancelActionPerformed(ActionEvent evt) {
		dispose();
	}
	
	protected void initGUI() {
		try {
			setTitle("Node Option");
			{
				jOK = new JButton();
				getContentPane().add(jOK);
				jOK.setText("OK");
				jOK.setBounds(55, 85, 60, 28);
				jOK.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jOKActionPerformed(evt);
					}
				});
			}
			{
				jCancel = new JButton();
				getContentPane().add(jCancel);
				jCancel.setText("Cancel");
				jCancel.setBounds(170, 85, 70, 28);
				jCancel.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jCancelActionPerformed(evt);
					}
				});
			}
			{
				jIDLabel = new JLabel();
				getContentPane().add(jIDLabel);
				jIDLabel.setText("ID:");
				jIDLabel.setBounds(63, 28, 63, 28);
			}
			{
				jID = new JTextField();
				getContentPane().add(jID);
				jID.setText(node.GetID());
				jID.setBounds(100, 30, 150, 28);
			}
			{
				getContentPane().setLayout(null);
			}
			setSize(316, 160);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}	
}
